#!/bin/sh
# BZFlag
# Copyright (c) 1993-2020 Tim Riker
#
# This package is free software;  you can redistribute it and/or
# modify it under the terms of the license found in the file
# named COPYING that should have accompanied this file.
#
# THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
# NOTE: update just the next two lines and then run this script
OLDCOPYRIGHTTEXT='Copyright (c) 1993-2016'
NEWCOPYRIGHTTEXT='Copyright (c) 1993-2017'
#
# update copyright in all files
#
# bzflag top-level dir
cd `git worktree list --porcelain | awk '$1 == "worktree" {print $2}'` || exit 1

myname=touchcopyright
tmpfile=$myname.tmp
rm -f $tmpfile
# touch myself last
files="`git ls-files | egrep -v misc/$myname'|\.(bmp|icns|ico|png|psd|wav)$'` misc/$myname"

# do replacement
for file in $files; do
  echo -e -n "$file\r"
  if [ ! -w ${file} ]; then
    echo "${file} not found or not writable."
    continue
  fi
  # cat to the file, not move to preserve permissions
  if sed -e "s/${OLDCOPYRIGHTTEXT}/${NEWCOPYRIGHTTEXT}/" < ${file} > $tmpfile ; then
    cat $tmpfile > ${file}
  fi
done
rm -f $tmpfile

# Local Variables: ***
# mode: sh ***
# tab-width: 8 ***
# sh-indentation: 2 ***
# sh-basic-offset: 2 ***
# indent-tabs-mode: t ***
# End: ***
# ex: shiftwidth=2 tabstop=8
